package com.adtech.adms.commons.web.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.UIBean;

import com.adtech.adms.system.pojo.Feature;
import com.opensymphony.xwork2.util.ValueStack;

/**
 * @author Dormin 
 * @since 2011-5-31 
 * 
 * @Copyright (C) AD Tech Workshop All Right Reserved
 */
public class PermissionComponent  extends  UIBean  {

	private String DEFAULT_TEMPLATE="permiss_simple";

	public PermissionComponent(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
	}


	/**
	 * 模块代码
	 */
	private Feature feature;

	private String image;

	private String href;
	private String icon;

	public String getIcon() {
		return icon;
	}



	public void setIcon(String icon) {
		this.icon = icon;
	}



	public String getImage() {
		return image;
	}



	public void setImage(String image) {
		this.image = image;
	}



	public Feature getFeature() {
		return feature;
	}



	public void setFeature(Feature feature) {
		this.feature = feature;
	}








	public String getHref() {
		return href;
	}



	public void setHref(String href) {
		this.href = href;
	}



	@Override
	protected String getDefaultTemplate() {
		return DEFAULT_TEMPLATE;
	}


	@Override
	public void evaluateParams() {
		super.evaluateParams();

		//addParameter("formatter", findValue(formatter, String.class));
		if (feature != null) {
			addParameter("image", image);
			addParameter("featureName", feature.getName());
			addParameter("enable", true);
			addParameter("href", href);
			addParameter("icon", icon);
		}else{
			addParameter("enable", false);
		}

	}




}
